﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
namespace Fcom.VNInsurance.Web.Controllers
{
    public class TravelController : Fcom.VNInsurance.Web.CultureHelper.CultureController
    {
        //
        // GET: /House/
        VNInsurance.Web.Models.VNInsuranceDataContext db = new Models.VNInsuranceDataContext();
        public ActionResult Index()
        {
            return View();
        }
        //InternationalTravel
        public ActionResult InternationalTravel()
        {
            if (User.Identity.IsAuthenticated)
            {
                Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                ViewBag.FullUserinfo = client.getUserInfo(User.Identity.Name);
            }
            var LangProduct = db.ProductLangs.Where(p => p.ProductID == 25 && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            var LangCatProduct = db.ProductCatLangs.Where(p => p.CatID == LangProduct.Product.ProductCat.ID && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            ViewBag.LangCat = LangCatProduct;
            ViewBag.productFAQ = db.ProductFAQs.Where(p => p.LangID == Request.Cookies["_culture"]["lang"] && p.ProductID == 25);
            ViewBag.location = db.LocationLangs.Where(m => m.LangID == Request.Cookies["_culture"]["lang"]);
            ViewBag.traveltype = db.TravelPolicyTypeLangs.Where(m => m.LangID == Request.Cookies["_culture"]["lang"]);
            var rets = db.PackageBenefits.Where(m => m.PackageProduct.ProductID == 25).Select(m=>m.BenefitID).Distinct();
            ViewBag.bene = rets;
            ViewBag.packagebenefit = db.PackageBenefits.Where(m => m.PackageProduct.ProductID == 25);
            ViewBag.benelang = db.BenefitLangs.Where(m => m.LangID == Request.Cookies["_culture"]["lang"]);
            ViewBag.packageproduct = db.PackageProducts.Where(m => m.ProductID == 25);
            ViewBag.packagelang = db.PackageLangs.Where(m => m.LangID == Request.Cookies["_culture"]["lang"]);
            return View(LangProduct);
        }
        [HttpPost]
        public ActionResult InternationalTravel(FormCollection formdata)
        {
            bool isauth = bool.Parse(formdata["isAuth"]);
            int idpackage = int.Parse(formdata["PackageID"]);
            var LangProduct = db.ProductLangs.Where(p => p.ProductID == 25 && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            var LangCatProduct = db.ProductCatLangs.Where(p => p.CatID == LangProduct.Product.ProductCat.ID && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            if (!isauth)
            {
                bool haveaccount = bool.Parse(formdata["haveAccount"]);
                if (haveaccount)
                {
                    return RedirectToAction("InternationalTravelCompare", new { PackageID = idpackage });
                //    return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName), package = idpackage });
                //
                }
                else
                {
                    int accounttype = int.Parse(formdata["accountype"]);
                    if (accounttype == 1)
                    {
                        bool gender = bool.Parse(formdata["gender"]);
                        string username = formdata["youremail"];
                        string phone = formdata["yourphone"];
                        string fullname = formdata["yourfullname"];
                        DateTime dateofbirth;
                        try
                        {
                            dateofbirth = DateTime.Parse(formdata["dateofBirth"]);
                        }
                        catch
                        {
                            dateofbirth = DateTime.Now;
                        }

                        Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                        if (client.CreateAccountFl(username, phone, fullname, gender, accounttype, dateofbirth))
                        {
                            FormsAuthentication.SetAuthCookie(username, true);
                        //    return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName), package = idpackage });
                        //
                            return RedirectToAction("InternationalTravelCompare", new { PackageID = idpackage });
                        }
                        client.Close();

                    }
                    else
                    {

                        string username = formdata["youremail"];
                        string phone = formdata["yourphone"];
                        string fullname = formdata["yourfullname"];
                        Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                        if (client.CreateAccountFl(username, phone, fullname, true, accounttype, DateTime.Now))
                        {
                            FormsAuthentication.SetAuthCookie(username, true);
                            return RedirectToAction("InternationalTravelCompare", new { PackageID = idpackage });
                            //return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName), package = idpackage });
                        
                        }
                        client.Close();
                    }
                }
            }
            else
            {
                //return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName), package=idpackage });
                return RedirectToAction("InternationalTravelCompare", new { PackageID = idpackage });
            }
            ViewBag.LangCat = LangCatProduct;

            ViewBag.productFAQ = db.ProductFAQs.Where(p => p.LangID == Request.Cookies["_culture"]["lang"] && p.ProductID == 4);

            return View(LangProduct);
        }
        public ActionResult InternationalTravelCompare(int PackageID)
        {
            var LangProduct = db.ProductLangs.Where(p => p.ProductID == 25 && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            ViewBag.LangProduct = LangProduct;
            var LangCatProduct = db.ProductCatLangs.Where(p => p.CatID == LangProduct.Product.ProductCat.ID && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            ViewBag.LangCat = LangCatProduct;
            ViewBag.productFAQ = db.ProductFAQs.Where(p => p.LangID == Request.Cookies["_culture"]["lang"] && p.ProductID == 25);
            var LangCPProduct = from cp in db.CompanyProductLangs
                                where cp.LangID == Request.Cookies["_culture"]["lang"] && cp.CompanyProduct.ProductID == 25 && cp.CompanyProduct.Enable == true && cp.CompanyProduct.Company.Enable == true && cp.CompanyProduct.PackageCompanyProducts.Where(m=>m.CompanyProductID==25).Select(m=>m.PackageID).FirstOrDefault()==PackageID
                                select new Fcom.VNInsurance.Web.Models.CPInfo() {  Condition = cp.Condition, ProductImage = cp.ProductImage, CompanyID = cp.CompanyProduct.CompanyID, CProductID = cp.CProductID, ProductName = cp.DisplayName, CompanyName = cp.CompanyProduct.Company.CompanyLangs.Where(n => n.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault().CompanyName, CompanyLogo = cp.CompanyProduct.Company.CompanyLangs.Where(n => n.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault().CompanyLogo, Benefit = cp.Benefit, Future = cp.Future, MoreInfo = cp.Moreinfo, Fare = cp.OneFare, InsuranceMoney = cp.InsuranceMoney };
            ViewBag.CurrentLang = LangProduct.Language;
            return View(LangCPProduct);

        }

        //DomesticTravel
        public ActionResult DomesticTravel()
        {
            if (User.Identity.IsAuthenticated)
            {
                Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                ViewBag.FullUserinfo = client.getUserInfo(User.Identity.Name);
            }
            var LangProduct = db.ProductLangs.Where(p => p.ProductID == 26 && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            var LangCatProduct = db.ProductCatLangs.Where(p => p.CatID == LangProduct.Product.ProductCat.ID && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            ViewBag.LangCat = LangCatProduct;

            ViewBag.productFAQ = db.ProductFAQs.Where(p => p.LangID == Request.Cookies["_culture"]["lang"] && p.ProductID == 26);

            return View(LangProduct);
        }
        [HttpPost]
        public ActionResult DomesticTravel(FormCollection formdata)
        {
            bool isauth = bool.Parse(formdata["isAuth"]);
            var LangProduct = db.ProductLangs.Where(p => p.ProductID == 26 && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            var LangCatProduct = db.ProductCatLangs.Where(p => p.CatID == LangProduct.Product.ProductCat.ID && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            if (!isauth)
            {
                bool haveaccount = bool.Parse(formdata["haveAccount"]);
                if (haveaccount)
                {
                    return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                }
                else
                {
                    int accounttype = int.Parse(formdata["accountype"]);
                    if (accounttype == 1)
                    {
                        bool gender = bool.Parse(formdata["gender"]);
                        string username = formdata["youremail"];
                        string phone = formdata["yourphone"];
                        string fullname = formdata["yourfullname"];
                        DateTime dateofbirth;
                        try
                        {
                            dateofbirth = DateTime.Parse(formdata["dateofBirth"]);
                        }
                        catch
                        {
                            dateofbirth = DateTime.Now;
                        }

                        Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                        if (client.CreateAccountFl(username, phone, fullname, gender, accounttype, dateofbirth))
                        {
                            FormsAuthentication.SetAuthCookie(username, true);
                            return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                        }
                        client.Close();

                    }
                    else
                    {

                        string username = formdata["youremail"];
                        string phone = formdata["yourphone"];
                        string fullname = formdata["yourfullname"];
                        Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                        if (client.CreateAccountFl(username, phone, fullname, true, accounttype, DateTime.Now))
                        {
                            FormsAuthentication.SetAuthCookie(username, true);
                            return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                        }
                        client.Close();
                    }
                }
            }
            else
            {
                return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
            }
            ViewBag.LangCat = LangCatProduct;

            ViewBag.productFAQ = db.ProductFAQs.Where(p => p.LangID == Request.Cookies["_culture"]["lang"] && p.ProductID == 4);

            return View(LangProduct);
        }
        //CargoInsurance
        public ActionResult CargoInsurance()
        {
            if (User.Identity.IsAuthenticated)
            {
                Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                ViewBag.FullUserinfo = client.getUserInfo(User.Identity.Name);
            }
            var LangProduct = db.ProductLangs.Where(p => p.ProductID == 27 && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            var LangCatProduct = db.ProductCatLangs.Where(p => p.CatID == LangProduct.Product.ProductCat.ID && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            ViewBag.LangCat = LangCatProduct;

            ViewBag.productFAQ = db.ProductFAQs.Where(p => p.LangID == Request.Cookies["_culture"]["lang"] && p.ProductID == 27);

            return View(LangProduct);
        }
        [HttpPost]
        public ActionResult CargoInsurance(FormCollection formdata)
        {
            bool isauth = bool.Parse(formdata["isAuth"]);
            var LangProduct = db.ProductLangs.Where(p => p.ProductID == 27 && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            var LangCatProduct = db.ProductCatLangs.Where(p => p.CatID == LangProduct.Product.ProductCat.ID && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            if (!isauth)
            {
                bool haveaccount = bool.Parse(formdata["haveAccount"]);
                if (haveaccount)
                {
                    return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                }
                else
                {
                    int accounttype = int.Parse(formdata["accountype"]);
                    if (accounttype == 1)
                    {
                        bool gender = bool.Parse(formdata["gender"]);
                        string username = formdata["youremail"];
                        string phone = formdata["yourphone"];
                        string fullname = formdata["yourfullname"];
                        DateTime dateofbirth;
                        try
                        {
                            dateofbirth = DateTime.Parse(formdata["dateofBirth"]);
                        }
                        catch
                        {
                            dateofbirth = DateTime.Now;
                        }

                        Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                        if (client.CreateAccountFl(username, phone, fullname, gender, accounttype, dateofbirth))
                        {
                            FormsAuthentication.SetAuthCookie(username, true);
                            return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                        }
                        client.Close();

                    }
                    else
                    {

                        string username = formdata["youremail"];
                        string phone = formdata["yourphone"];
                        string fullname = formdata["yourfullname"];
                        Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                        if (client.CreateAccountFl(username, phone, fullname, true, accounttype, DateTime.Now))
                        {
                            FormsAuthentication.SetAuthCookie(username, true);
                            return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                        }
                        client.Close();
                    }
                }
            }
            else
            {
                return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
            }
            ViewBag.LangCat = LangCatProduct;

            ViewBag.productFAQ = db.ProductFAQs.Where(p => p.LangID == Request.Cookies["_culture"]["lang"] && p.ProductID == 4);

            return View(LangProduct);
        }
        //TravelCard
        public ActionResult TravelCard()
        {
            if (User.Identity.IsAuthenticated)
            {
                Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                ViewBag.FullUserinfo = client.getUserInfo(User.Identity.Name);
            }
            var LangProduct = db.ProductLangs.Where(p => p.ProductID == 28 && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            var LangCatProduct = db.ProductCatLangs.Where(p => p.CatID == LangProduct.Product.ProductCat.ID && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            ViewBag.LangCat = LangCatProduct;

            ViewBag.productFAQ = db.ProductFAQs.Where(p => p.LangID == Request.Cookies["_culture"]["lang"] && p.ProductID == 28);

            return View(LangProduct);
        }
        [HttpPost]
        public ActionResult TravelCard(FormCollection formdata)
        {
            bool isauth = bool.Parse(formdata["isAuth"]);
            var LangProduct = db.ProductLangs.Where(p => p.ProductID == 28 && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            var LangCatProduct = db.ProductCatLangs.Where(p => p.CatID == LangProduct.Product.ProductCat.ID && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            if (!isauth)
            {
                bool haveaccount = bool.Parse(formdata["haveAccount"]);
                if (haveaccount)
                {
                    return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                }
                else
                {
                    int accounttype = int.Parse(formdata["accountype"]);
                    if (accounttype == 1)
                    {
                        bool gender = bool.Parse(formdata["gender"]);
                        string username = formdata["youremail"];
                        string phone = formdata["yourphone"];
                        string fullname = formdata["yourfullname"];
                        DateTime dateofbirth;
                        try
                        {
                            dateofbirth = DateTime.Parse(formdata["dateofBirth"]);
                        }
                        catch
                        {
                            dateofbirth = DateTime.Now;
                        }

                        Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                        if (client.CreateAccountFl(username, phone, fullname, gender, accounttype, dateofbirth))
                        {
                            FormsAuthentication.SetAuthCookie(username, true);
                            return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                        }
                        client.Close();

                    }
                    else
                    {

                        string username = formdata["youremail"];
                        string phone = formdata["yourphone"];
                        string fullname = formdata["yourfullname"];
                        Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                        if (client.CreateAccountFl(username, phone, fullname, true, accounttype, DateTime.Now))
                        {
                            FormsAuthentication.SetAuthCookie(username, true);
                            return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                        }
                        client.Close();
                    }
                }
            }
            else
            {
                return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
            }
            ViewBag.LangCat = LangCatProduct;

            ViewBag.productFAQ = db.ProductFAQs.Where(p => p.LangID == Request.Cookies["_culture"]["lang"] && p.ProductID == 4);

            return View(LangProduct);
        }
        //HotelBooking
        public ActionResult HotelBooking()
        {
            if (User.Identity.IsAuthenticated)
            {
                Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                ViewBag.FullUserinfo = client.getUserInfo(User.Identity.Name);
            }
            var LangProduct = db.ProductLangs.Where(p => p.ProductID == 29&& p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            var LangCatProduct = db.ProductCatLangs.Where(p => p.CatID == LangProduct.Product.ProductCat.ID && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            ViewBag.LangCat = LangCatProduct;

            ViewBag.productFAQ = db.ProductFAQs.Where(p => p.LangID == Request.Cookies["_culture"]["lang"] && p.ProductID == 29);

            return View(LangProduct);
        }
        [HttpPost]
        public ActionResult HotelBooking(FormCollection formdata)
        {
            bool isauth = bool.Parse(formdata["isAuth"]);
            var LangProduct = db.ProductLangs.Where(p => p.ProductID == 29 && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            var LangCatProduct = db.ProductCatLangs.Where(p => p.CatID == LangProduct.Product.ProductCat.ID && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            if (!isauth)
            {
                bool haveaccount = bool.Parse(formdata["haveAccount"]);
                if (haveaccount)
                {
                    return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                }
                else
                {
                    int accounttype = int.Parse(formdata["accountype"]);
                    if (accounttype == 1)
                    {
                        bool gender = bool.Parse(formdata["gender"]);
                        string username = formdata["youremail"];
                        string phone = formdata["yourphone"];
                        string fullname = formdata["yourfullname"];
                        DateTime dateofbirth;
                        try
                        {
                            dateofbirth = DateTime.Parse(formdata["dateofBirth"]);
                        }
                        catch
                        {
                            dateofbirth = DateTime.Now;
                        }

                        Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                        if (client.CreateAccountFl(username, phone, fullname, gender, accounttype, dateofbirth))
                        {
                            FormsAuthentication.SetAuthCookie(username, true);
                            return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                        }
                        client.Close();

                    }
                    else
                    {

                        string username = formdata["youremail"];
                        string phone = formdata["yourphone"];
                        string fullname = formdata["yourfullname"];
                        Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                        if (client.CreateAccountFl(username, phone, fullname, true, accounttype, DateTime.Now))
                        {
                            FormsAuthentication.SetAuthCookie(username, true);
                            return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                        }
                        client.Close();
                    }
                }
            }
            else
            {
                return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
            }
            ViewBag.LangCat = LangCatProduct;

            ViewBag.productFAQ = db.ProductFAQs.Where(p => p.LangID == Request.Cookies["_culture"]["lang"] && p.ProductID == 4);

            return View(LangProduct);
        }
        //TravelBooking
        public ActionResult TravelBooking()
        {
            if (User.Identity.IsAuthenticated)
            {
                Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                ViewBag.FullUserinfo = client.getUserInfo(User.Identity.Name);
            }
            var LangProduct = db.ProductLangs.Where(p => p.ProductID == 30 && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            var LangCatProduct = db.ProductCatLangs.Where(p => p.CatID == LangProduct.Product.ProductCat.ID && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            ViewBag.LangCat = LangCatProduct;

            ViewBag.productFAQ = db.ProductFAQs.Where(p => p.LangID == Request.Cookies["_culture"]["lang"] && p.ProductID == 30);

            return View(LangProduct);
        }
        [HttpPost]
        public ActionResult TravelBooking(FormCollection formdata)
        {
            bool isauth = bool.Parse(formdata["isAuth"]);
            var LangProduct = db.ProductLangs.Where(p => p.ProductID == 30 && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            var LangCatProduct = db.ProductCatLangs.Where(p => p.CatID == LangProduct.Product.ProductCat.ID && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            if (!isauth)
            {
                bool haveaccount = bool.Parse(formdata["haveAccount"]);
                if (haveaccount)
                {
                    return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                }
                else
                {
                    int accounttype = int.Parse(formdata["accountype"]);
                    if (accounttype == 1)
                    {
                        bool gender = bool.Parse(formdata["gender"]);
                        string username = formdata["youremail"];
                        string phone = formdata["yourphone"];
                        string fullname = formdata["yourfullname"];
                        DateTime dateofbirth;
                        try
                        {
                            dateofbirth = DateTime.Parse(formdata["dateofBirth"]);
                        }
                        catch
                        {
                            dateofbirth = DateTime.Now;
                        }

                        Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                        if (client.CreateAccountFl(username, phone, fullname, gender, accounttype, dateofbirth))
                        {
                            FormsAuthentication.SetAuthCookie(username, true);
                            return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                        }
                        client.Close();

                    }
                    else
                    {

                        string username = formdata["youremail"];
                        string phone = formdata["yourphone"];
                        string fullname = formdata["yourfullname"];
                        Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                        if (client.CreateAccountFl(username, phone, fullname, true, accounttype, DateTime.Now))
                        {
                            FormsAuthentication.SetAuthCookie(username, true);
                            return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                        }
                        client.Close();
                    }
                }
            }
            else
            {
                return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
            }
            ViewBag.LangCat = LangCatProduct;

            ViewBag.productFAQ = db.ProductFAQs.Where(p => p.LangID == Request.Cookies["_culture"]["lang"] && p.ProductID == 4);

            return View(LangProduct);
        }

    }
}
